<!DOCTYPE html>
<html>
  <head>
  	<div th:include="base-libs :: base-libs" />
    <title>完成服务</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <style>
    	#fixedBox{
			text-align:right;
			overflow:hidden;
			border:0;
			padding-right:30px;
			border-top:1px solid #ddd;
		}
		#fixedBox button{
			margin-right:10px;
			padding-right:20px;
		}
		#cancel{
			border: 1px solid #dedede;
		    background-color: #f1f1f1;
		    color: #333;
		}
		.laydate_box{
			top:0 !important
		}
		.laydate-icon{
			border:1px solid #B6B6B6;
			height:28px;
			line-height:28px;
			width:85% !important;
		}
		.td-context{
			width:130px;
		}
		td{
			white-space: nowrap;text-overflow: ellipsis;overflow: hidden;
		}
		/*浮雕字体css*/
		.fdztCss{
			text-shadow: 1px 1px 0 rgba(255, 255, 255, .7);
			color:#ccc;
		}
    </style>
	<script th:inline="javascript">
        var XM = [[${XM}]];
    </script>
    <script>
    	var taskData = StoreCache.removeCache("taskData");
    	$(function(){
    		initView();
    		initData();
    	})
    	
    	function initView(){
    		$("#confirmBtn").click(function(){
    				if($("#SJFWSJ,#BZ").QuickValidate()){
    					var fpfwArr = [{
		    				FPFWID: taskData.FPFWID,
		    				SJFWSJ: $("#SJFWSJ").val(),
		    				BZ: $("#BZ").val(),
		    				FWZT:'1',
		    				method: 'update'
		    			}]
		    			$.QuickRemote.AjaxJson(contextRoot + "wdqyhz/save", function(result){
		    				if(result.state){
		    					$.QuickAlert.alertNormal(result.info.success, {callback: function(){
		    						StoreCache.setCache("refresh",true);
		    						closeView();
		    					}});
		    				}else{
		    					var info = result["info"];
		    					$.QuickAlert.alertFail({content: info["faultInfo"]});
		    				}
		    			}, {fpfwArr: JSON.stringify(fpfwArr)});
    				}
    		})
    	}
    	
    	function initData(){
    		//查询相关服务次数
			$.QuickRemote.AjaxJson(contextRoot + "wdqyhz/queryNumberOfYwcrw", function(result){
				  if(result.state){
			        var SYFWCS = 0;
			        if(!StringUtils.isEmpty(result.FWPC)){
			            //服务包
                    	SYFWCS = parseInt(result.FWPC)-parseInt(result.YFWCS);//剩余服务次数=服务频次-已服务次数
					}else{
			            //医保服务项
                        SYFWCS = parseInt(result.FWCS)-parseInt(result.YFWCS);//剩余服务次数=服务次数-已服务次数
					}
				  	$(".SYFWCS").html(SYFWCS);
				  	$(".YFWCS").html(result.YFWCS);
				  }else{
				  	$.QuickAlert.alertFail({content: result.info});
				  }
			}, {QYXXID: taskData.QYXXID, FWBID: taskData.FWBID, FWID: taskData.FWID});
    		
			var onlyQuery = StoreCache.removeCache("onlyQuery");
    		if(!StringUtils.isEmpty(taskData.SJFWSJ) || onlyQuery){
				$("#SJFWSJ,#BZ,#fixedBox").remove();
				/*实际服务人员*/
                if(StringUtils.isEmpty(taskData.SJFWRY)) taskData.SJFWRY = taskData.FWRY;//针对以前记录
			}else{
				$(".SJFWSJ").removeClass("SJFWSJ");
				$(".BZ").removeClass("BZ");
				$("#fixedBox").css("visibility","visible");
				/*实际服务人员*/
				if(StringUtils.isEmpty(taskData.SJFWRY)) taskData.SJFWRY = XM;
			}
			var timeReg = /^(\d{4}-\d{2}-\d{2})\s+\d{2}:\d{2}:\d{2}/;
    		for(var key in taskData){
				  $("."+key).html(taskData[key].replace(timeReg,'$1'))
					  .attr('title',taskData[key].replace(timeReg,'$1'));
			}
			var FWBMC = $(".FWBMC").html();
			if(StringUtils.isEmpty(FWBMC)){
                $(".FWBMC").html("医保服务项").attr("title","医保服务项").addClass("fdztCss")
			}
    	}
    	
    	
    	
    	/** 取消  */
    	function closeView(){
    		parent.layer.closeAll();
    	}
    </script>

  </head>
  
  <body class="easyui-layout" border="false">
  	<div region="center" fit="true" border="false">
	    <table id="fprwTable" class="form-table" style="margin-top:10px;table-layout: fixed;">
					<tr>
						<td class="td-text">签约居民</td>
						<td class="XM td-context"></td>
						<td class="td-text">签约服务包</td>
						<td class="FWBMC td-context"></td>
						<td class="td-text">签约团队</td>
						<td class="QYTD td-context"></td>
					</tr>
					<tr>
						<td class="td-text">服务项名称</td>
						<td class="FWMC"></td>
						<td class="td-text" style="width:105px;">已提供服务次数</td>
						<td class="YFWCS"></td>
						<td class="td-text">剩余服务次数</td>
						<td class="SYFWCS"></td>
					</tr>
					<tr>
						<td class="td-text">服务项内容</td>
						<td class="FWNR" colspan="5"></td>
					</tr>
					<tr>
						<td class="td-text">实际服务人员</td>
						<td class="SJFWRY"></td>
						<td class="td-text">服务人员</td>
						<td class="FWRY"></td>
						<td class="td-text">服务对象</td>
						<td class="FWDX"></td>
					</tr>
					<tr>
						<td class="td-text">实际服务时间</td>
						<td class="SJFWSJ">
							<input id="SJFWSJ" class="laydate-icon" onclick="laydate()" quick-config="label:'实际服务时间', validateProxy:'notNull'" />
						</td>
						<td class="td-text">预期服务时间</td>
						<td class="YQFWSJ" colspan="3"></td>
					</tr>
					<tr>
						<td class="td-text">备注</td>
						<td class="BZ" colspan="5">
							<input id="BZ" quick-config="label:'备注', validateProxy:'length',length:'200'" />
						</td>
					</tr>
		</table>
  	</div>
  	
  	<div region="south" id="fixedBox" class="layui-layer-btn" style="height:50px;line-height:50px;overflow:hidden;visibility:hidden;border:0;padding-right:30px;">
		<button class="layui-layer-btn0" type="button" id="confirmBtn">确定</button>
		<button id="cancel" class="layui-layer-btn1" type="button" onclick="closeView()">取消</button>
	</div>
  </body>
</html>
